﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FRW.Common.Extensions;

namespace Money
{
    public class Accounts : EventList<Account>
    {
        private static Accounts _accounts;

        public const string AllAccounts = "[ALL]";

        // TODO check that this is safe and whether it should be a singleton
        public static Accounts GetAccounts()
        {
            return _accounts;
        }

        public Accounts()
        {
            _accounts = this;
        }

        public Account GetAccount(string accountName)
        {
            foreach (Account acc in this.ToList())
            {
                if (acc.Name.Equals(accountName))
                {
                    return acc;
                }
            }

            return null;
        }
    }
}
